import QtQuick 1.0
import com.nokia.symbian 1.0
import "../js/Storage.js" as Storage
import "../delegate"

PurePage {
    id: sessionOpenTimePage

    anchors { fill: parent; topMargin: statusBar.height; bottomMargin: toolBar.height }
    signal downloadTime(int days)
    signal reloadSchedule

    ListModel {
        id: sessionScheduleModel
    }

    ListModel {
        id: storageScheduleModel
    }

    LodingIndicator {
        id: lodingSessionOpenTimePage
    }

    Component {
        id: sessionOpenTimeHeadingItem

        Rectangle {
            id: sessionOpenTimeHeadingRect

            width: screen.width
            height: childrenRect.height
            color: "#5bc658"

            Text {
                text: section
                font.bold: true
            }

        }
    }

    ListView {
        id: sessionScheduleListView

        anchors { fill: parent}
        cacheBuffer: 2 * height
        delegate: SessionScheduleDelegate {}
        model: sessionScheduleModel

        section.property: "schedule"
        section.criteria: ViewSection.FullString
        section.delegate: sessionOpenTimeHeadingItem

    }

    ScrollBar {
        flickableItem: sessionScheduleListView
        anchors { right: sessionScheduleListView.right; top: sessionScheduleListView.top }
    }

    onDownloadTime: {
       sessionScheduleModel.clear();
       Storage.getSessionScheduleCache(days, sessionScheduleModel);

    }



}
